package com.itheima.exerciseTest.method40_49.method43;

public class Test {
    public static void main(String[] args) {
//        String name()	获取枚举项的名称
        System.out.println(Week.星期一);
        System.out.println("===========================");

//        int ordinal()	返回枚举项在枚举类中的索引值
        int index1 = Week.星期一.ordinal();
        int index2 = Week.星期二.ordinal();
        int index3 = Week.星期三.ordinal();
        int index4 = Week.星期四.ordinal();
        int index5 = Week.星期五.ordinal();
        int index6 = Week.星期六.ordinal();
        int index7 = Week.星期天.ordinal();
        System.out.println(index1);
        System.out.println(index2);
        System.out.println(index3);
        System.out.println(index4);
        System.out.println(index5);
        System.out.println(index6);
        System.out.println(index7);
        System.out.println("===========================");

//        int compareTo(E o)	比较两个枚举项，返回的是索引值的差值
        int compareTo = Week.星期一.compareTo(Week.星期天);
        System.out.println(compareTo);
        System.out.println("===========================");

//        String toString()	返回枚举常量的名称
        String s = Week.星期一.toString();
        System.out.println(s);
        System.out.println("===========================");

//        static <T> T valueOf(Class<T> type,String name)	 获取指定枚举类中的指定名称的枚举值
        Week valueOf = Enum.valueOf(Week.class, "星期天");
        System.out.println(valueOf);
        System.out.println("===========================");

//        values()	获得所有的枚举项
        Week[] values = Week.values();
        for (Week value : values) {
            System.out.println(value);
        }
    }
}
